package com.etc.util;

import com.etc.pojo.ResultMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class MessageUtils {
    public static String getMessage(boolean isSystemMessage,String fromName,Object message) throws JsonProcessingException {
        ResultMessage resultMessage =new ResultMessage();
        resultMessage.setSystem(isSystemMessage);
        resultMessage.setMessage(message);
        if(fromName !=null){
            resultMessage.setFromName(fromName);
        }
        ObjectMapper mapper= new ObjectMapper();
        return mapper.writeValueAsString(resultMessage);


    }
}
